package com.xj.admin.bussiness.deviceInformation.web;

import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.plugins.Page;
import com.feilong.core.Validator;
import com.xj.admin.base.index.web.BaseController;
import com.xj.admin.bussiness.deviceInformation.service.TbDeviceInformationService;
import com.xj.admin.bussiness.deviceInformationImg.service.ITbDeviceInformationImgService;
import com.xj.admin.bussiness.personalInformationImg.service.ITbPersonalInformationImgService;
import com.xj.admin.bussiness.qrext4j.src.main.java.org.iherus.codegen.qrcode.SimpleQrcodeGenerator;
import com.xj.admin.bussiness.reference.service.YzUserMachinReferenceService;
import com.xj.admin.bussiness.registerLicense.service.ITbRegisterLicenseService;
import com.xj.admin.bussiness.transferLicense.service.ITbTransferLicenseService;
import com.xj.admin.bussiness.userInfo.service.ITbUserInfoService;
import com.xj.admin.util.Excel.ExcelUtil;
import com.xj.admin.util.JsonUtil;
import com.xj.admin.util.dtgrid.model.Pager;
import com.xj.common.base.common.bean.AbstractBean;
import com.xj.common.base.common.exception.EnumSvrResult;
import com.xj.common.bussiness.deviceInformation.entity.DeviceInfoMould;
import com.xj.common.bussiness.deviceInformation.entity.TbDeviceInformation;
import com.xj.common.bussiness.deviceInformationImg.entity.TbDeviceInformationImg;
import com.xj.common.bussiness.personalInformationImg.entity.TbPersonalInformationImg;
import com.xj.common.bussiness.registerLicense.entity.TbRegisterLicense;
import com.xj.common.bussiness.registerLicense.entity.registerLicenseMould;
import com.xj.common.bussiness.transferLicense.entity.TbTransferLicense;
import com.xj.common.bussiness.transferLicense.entity.transferLicenseMould;
import com.xj.common.bussiness.user.entity.TbUser;
import com.xj.common.bussiness.userInfo.entity.TbUserInfo;
import lombok.extern.slf4j.Slf4j;
import org.junit.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.*;
/**
 * 　　　　　　　　┏┓　　　┏┓+ +
 * 　　　　　　　┏┛┻━━━┛┻┓ + +
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┃　　　━　　　┃ ++ + + +
 * 　　　　　　 ████━████ ┃+
 * 　　　　　　　┃　　　　　　　┃ +
 * 　　　　　　　┃　　　┻　　　┃
 * 　　　　　　　┃　　　　　　　┃ + +
 * 　　　　　　　┗━┓　　　┏━┛
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃ + + + +
 * 　　　　　　　　　┃　　　┃　　　　Code is far away from bug with the animal protecting
 * 　　　　　　　　　┃　　　┃ + 　　　　神兽保佑,代码无bug
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃　　+
 * 　　　　　　　　　┃　 　　┗━━━┓ + +
 * 　　　　　　　　　┃ 　　　　　　　┣┓
 * 　　　　　　　　　┃ 　　　　　　　┏┛
 * 　　　　　　　　　┗┓┓┏━┳┓┏┛ + + + +
 * 　　　　　　　　　　┃┫┫　┃┫┫
 * 　　　　　　　　　　┗┻┛　┗┻┛+ + + +
 * <p>
 * Created by hezhao on 2018-08-16 16:33
 */

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Hmemb
 * @since 2018-03-27
 */
@Controller
@Slf4j
@RequestMapping("/deviceInformation/")
public class TbDeviceInformationController extends BaseController {

    @Autowired
    private TbDeviceInformationService deviceInformationService;
    @Autowired
    private ITbTransferLicenseService transferLicenseService;
    @Autowired
    private ITbRegisterLicenseService registerLicenseService;
    @Autowired
    private ITbUserInfoService userInfoService;
    @Autowired
    private ITbPersonalInformationImgService personalInformationImgService;
    @Autowired
    private ITbDeviceInformationImgService deviceInformationImgService;


    @GetMapping("listUI")
    public String listUI() {
        return "deviceInformation/list";
    }

    @GetMapping("form")
    public String form(Map<String, Object> map) {
        return "deviceInformation/form";
    }

    @GetMapping("search")
    public String search() {
        return "deviceInformation/search";
    }

    @GetMapping("addDeviceImg")
    public String addDeviceImg() {
        return "deviceInformation/addDeviceImg";
    }

    @GetMapping("addUserImg")
    public String addUserImg() {
        return "deviceInformation/addUserImg";
    }

    @PostMapping("list")
    @ResponseBody
    public Object list(String gridPager) {
        Pager pager = JsonUtil.getObjectFromJson(gridPager, Pager.class);
        Map<String, Object> parameters = null;
        if (Validator.isNullOrEmpty(pager.getParameters())) {
            parameters = new HashMap<>();
        } else {
            parameters = pager.getParameters();
        }
        Page<TbDeviceInformation> list = deviceInformationService.selectPage(new Page<TbDeviceInformation>
                (pager.getNowPage(), pager.getPageSize()), Condition.create().allEq(parameters).orderBy("id", false));
        makeGridResult(parameters, pager, list);
//        System.out.println("list:"+list);
//        for(int i =0;i<list.getTotal();i++){
//            System.out.println(list.getTotal());
//        }
        //数据导出
//        ExcelUtil<TbDeviceInformation> util = new ExcelUtil<TbDeviceInformation>();
//        // 准备数据
//        List<TbDeviceInformation> list1 = new ArrayList<>();
//        for (int i = 0; i < 10; i++) {
//            list1.add();
//
//        }
//        String[] columnNames = {"ID", "姓名", "性别"};
//        try {
//            util.exportExcel("设备信息导出", columnNames, list1, new FileOutputStream("E:/test.xls"), ExcelUtil.EXCEL_FILE_2003);
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        }
        return parameters;
    }

    @PostMapping("saveForm")
    @ResponseBody
    public AbstractBean add(TbDeviceInformation tbdeviceinformation) {
        AbstractBean bean = new AbstractBean();
        //Map<String,Object> map = new HashMap<>();
        System.out.println("++++++++++++++++++++++++++++++++++++++" + tbdeviceinformation);

        //新增用户备案信息
        TbUserInfo tbUserInfo = new TbUserInfo();
        tbUserInfo.setCreateDate(new Date());
        tbUserInfo.setIdentification(tbdeviceinformation.getIdentification());
        tbUserInfo.setRegisterName(tbdeviceinformation.getDeviceRegisterName());
        userInfoService.insert(tbUserInfo);
        //System.out.println("新增的用户信息++++++++++++++++："+tbdeviceinformation.getRegisterName()+tbdeviceinformation.getIdentification());

        //插入上户记录信息
        TbRegisterLicense registerLicense = new TbRegisterLicense();
        registerLicense.setFactoryNum(tbdeviceinformation.getFactoryNum());
        registerLicense.setIdentification(tbdeviceinformation.getIdentification());
        registerLicense.setCreateDate(new Date());
        registerLicenseService.insert(registerLicense);
        //System.out.println("新增的上户记录信息++++++++++++++++："+tbdeviceinformation.getIdentification()+tbdeviceinformation.getFactoryNum());

        //插入过户记录信息
        TbTransferLicense tbTransferLicense = new TbTransferLicense();
        tbTransferLicense.setIdentification(tbdeviceinformation.getIdentification());
        tbTransferLicense.setFactoryNum(tbdeviceinformation.getFactoryNum());
        tbTransferLicense.setCreateDate(new Date());
        transferLicenseService.insert(tbTransferLicense);
        //System.out.println("新增的过户记录信息++++++++++++++++："+tbdeviceinformation.getIdentification()+tbdeviceinformation.getFactoryNum());

        //新增用户备案图片信息
        TbPersonalInformationImg tbPersonalInformationImg = new TbPersonalInformationImg();
        tbPersonalInformationImg.setUserInfoId(tbUserInfo.getId());
        tbPersonalInformationImg.setCreateDate(new Date());
        tbPersonalInformationImg.setIdentityNum(tbdeviceinformation.getIdentification());
        personalInformationImgService.insert(tbPersonalInformationImg);

        //新增设备备案图片信息
        TbDeviceInformationImg tbDeviceInformationImg = new TbDeviceInformationImg();
        tbDeviceInformationImg.setDeviceInformationId(tbdeviceinformation.getId());
        tbDeviceInformationImg.setCreateDate(new Date());
        tbDeviceInformationImg.setBigShelfNum(tbdeviceinformation.getFactoryNum());
        tbDeviceInformationImg.setIdentityNum(tbdeviceinformation.getIdentification());
        deviceInformationImgService.insert(tbDeviceInformationImg);
        if (tbdeviceinformation.getId() == null) {
            tbdeviceinformation.setCreateDate(new Date());
        }
        if (!deviceInformationService.insertOrUpdate(tbdeviceinformation)) {
            bean.setStatus(EnumSvrResult.ERROR.getVal());
            bean.setMessage(EnumSvrResult.ERROR.getName());
        }
        return bean;
    }

    @PostMapping("saveEdit")
    @ResponseBody
    public AbstractBean addEdit(TbDeviceInformation tbdeviceinformation) {
        AbstractBean bean = new AbstractBean();
       // Map<String, Object> parameters = null;
        System.out.println("++++++++++++++++++++++++++++++++++++++" + tbdeviceinformation);

        //编辑userInfo用户名
        TbUserInfo info= new TbUserInfo();
        info.setIdentification(tbdeviceinformation.getIdentification());
        List<TbUserInfo> userInfoList = userInfoService.getTbuserInfo(info);
        userInfoList.get(0).setRegisterName(tbdeviceinformation.getDeviceRegisterName());
        userInfoService.updateName(userInfoList.get(0));

        //编辑deviceInformationImg出厂编号，registerLicense出厂编号，transferLicense出厂编号
        TbDeviceInformationImg tbDeviceInformationImg = new TbDeviceInformationImg();
        TbRegisterLicense tbRegisterLicense = new TbRegisterLicense();
        TbTransferLicense tbTransferLicense = new TbTransferLicense();

        tbDeviceInformationImg.setIdentityNum(tbdeviceinformation.getIdentification());
        tbRegisterLicense.setIdentification(tbdeviceinformation.getIdentification());
        tbTransferLicense.setIdentification(tbdeviceinformation.getIdentification());

        List<TbDeviceInformationImg> deviceInformationImgList = deviceInformationImgService.getTbdeviceInformationImg(tbDeviceInformationImg);
        List<TbRegisterLicense> registerLicenseList = registerLicenseService.getRegisterLicense(tbRegisterLicense);
        List<TbTransferLicense> transferLicenseList = transferLicenseService.getTransferLicense(tbTransferLicense);

        deviceInformationImgList.get(0).setBigShelfNum(tbdeviceinformation.getFactoryNum());
        registerLicenseList.get(0).setFactoryNum(tbdeviceinformation.getFactoryNum());
        transferLicenseList.get(0).setFactoryNum(tbdeviceinformation.getFactoryNum());

        deviceInformationImgService.updateFactoryNum(deviceInformationImgList.get(0));
        registerLicenseService.updateFactoryNum(registerLicenseList.get(0));
        transferLicenseService.updateFactoryNum(transferLicenseList.get(0));

        if (!deviceInformationService.insertOrUpdate(tbdeviceinformation)) {
            bean.setStatus(EnumSvrResult.ERROR.getVal());
            bean.setMessage(EnumSvrResult.ERROR.getName());
        }
        return bean;
    }

    @DeleteMapping("{id}/delete")
    @ResponseBody
    public AbstractBean delete(@PathVariable(required = true) Integer id) {
        if (!deviceInformationService.deleteById(id)) {
            return error();
        }
        return success();
    }

    @GetMapping("{id}/select")
    public String select(Map<String, Object> map, @PathVariable(required = true) Integer id) {
        TbDeviceInformation tbdeviceinformation = deviceInformationService.selectById(id);
        map.put("record", tbdeviceinformation);
        return "deviceInformation/edit";
    }

    //编辑读取状态
    @GetMapping("{id}/editState")
    public String editState(Map<String, Object> map, @PathVariable(required = true) Integer id) {
        TbDeviceInformation tbdeviceinformation = deviceInformationService.selectById(id);
        map.put("record", tbdeviceinformation);
        return "deviceInformation/editState";
    }

    //添加设备照片
    @GetMapping("{id}/addDeviceImg")
    public String addDeviceImg(Map<String, Object> map, @PathVariable(required = true) Integer id) {
        TbDeviceInformation tbdeviceinformation = deviceInformationService.selectById(id);
        map.put("record", tbdeviceinformation);
        return "deviceInformation/addDeviceImg";
    }

    //添加用户照片
    @GetMapping("{id}/addUserImg")
    public String addUserImg(Map<String, Object> map, @PathVariable(required = true) Integer id) {
        TbDeviceInformation tbdeviceinformation = deviceInformationService.selectById(id);
        map.put("record", tbdeviceinformation);
        return "deviceInformation/addUserImg";
    }

    //详情页面
    @GetMapping("{id}/details")
    public String details(Map<String, Object> map, @PathVariable(required = true) Integer id) {
        TbDeviceInformation deviceInformation = new TbDeviceInformation();
        deviceInformation.setId(id);
//		TbUser user = SessionUtil.getloginUser();
//		String srcImgPath = "F:/ye/backimg.jpg";
//		String logoText = user.getUserName();
//		String targerPath = "F:/ye/fly.jpg";
//		//ImageMarkLogoByIcon.markImageByText(logoText, srcImgPath, targerPath,-45);
//		markImageByMoreText(logoText, srcImgPath, targerPath);
        List<DeviceInfoMould> deviceInformationList = deviceInformationService.searchDevcieInformationList(deviceInformation);
        System.out.println("+++++++++++++++++++++++++++++++++++++++" + deviceInformationList);

        List<String> urlList = new ArrayList<>();
        List<String> userList = new ArrayList<>();
        List<String> invoiceList = new ArrayList<>();

        for (int i = 0; i < deviceInformationList.size(); i++) {
            //System.out.println("++++++获取referenceDeviceImg的值="+ deviceInformationList.get(i).getReferenceDeviceImg());
            String urlDevice = deviceInformationList.get(i).getReferenceDeviceImg();
            String[] urlDeviceList = urlDevice.split(",");
            for (int j = 0; j < urlDeviceList.length; j++) {
                System.out.println(urlDeviceList[j]);
                urlList.add(urlDeviceList[j]);
            }
            //System.out.println("+++++返回前端的值=" + urlList);
        }
        for (int k = 0; k < deviceInformationList.size(); k++) {
            //System.out.println("------获取ReferenceUserImg的值="+ deviceInformationList.get(k).getReferenceUserImg());
            String urlUser1 = deviceInformationList.get(k).getReferenceUserImg();
            String[] urlUserList = urlUser1.split(",");
            for (int a = 0; a < urlUserList.length; a++) {
                //System.out.println(urlUserList[a]);
                userList.add(urlUserList[a]);
            }
            //System.out.println("------返回前端的值=" + userList);
        }
        for (int l = 0; l < deviceInformationList.size(); l++) {
            //System.out.println("*******获取ReferenceInvoiceImg的值="+ deviceInformationList.get(l).getReferenceInvoiceImg());
            String urlInvoice = deviceInformationList.get(l).getReferenceInvoiceImg();
            String[] urlInvoiceList = urlInvoice.split(",");
            for (int b = 0; b < urlInvoiceList.length; b++) {
                //System.out.println(urlInvoiceList[b]);
                invoiceList.add(urlInvoiceList[b]);
            }
            //System.out.println("*******返回前端的值=" + invoiceList);
        }
        map.put("urlList", urlList);
        map.put("userList", userList);
        map.put("invoiceList", invoiceList);
        map.put("deviceInformationList", deviceInformationList);
        return "deviceInformation/details";
    }

    //搜索详情页面
    @GetMapping("{id}/detailsSearch")
    public String detailsSearch(Map<String, Object> map, @PathVariable(required = true) Integer id) {
        TbDeviceInformation deviceInformations = new TbDeviceInformation();
        deviceInformations.setId(id);
        List<DeviceInfoMould> deviceInformationList = deviceInformationService.searchDevcieInformationList(deviceInformations);
        System.out.println("+++++++++++++++++++++++++++++++++++++++" + deviceInformationList);

        List<String> urlList = new ArrayList<>();
        List<String> userList = new ArrayList<>();
        List<String> invoiceList = new ArrayList<>();

        for (int i = 0; i < deviceInformationList.size(); i++) {
            String UrlDevice = deviceInformationList.get(i).getReferenceDeviceImg();
            String[] urlDeviceList = UrlDevice.split(",");
            for (int j = 0; j < urlDeviceList.length; j++) {
                System.out.println(urlDeviceList[j]);
                urlList.add(urlDeviceList[j]);
            }
        }
        for (int k = 0; k < deviceInformationList.size(); k++) {
            String UrlUser = deviceInformationList.get(k).getReferenceUserImg();
            String[] urlUserList = UrlUser.split(",");
            for (int a = 0; a < urlUserList.length; a++) {
                userList.add(urlUserList[a]);
            }
        }
        for (int l = 0; l < deviceInformationList.size(); l++) {
            String UrlInvoice = deviceInformationList.get(l).getReferenceInvoiceImg();
            String[] urlInvoiceList = UrlInvoice.split(",");
            for (int b = 0; b < urlInvoiceList.length; b++) {
                invoiceList.add(urlInvoiceList[b]);
            }
        }
        map.put("urlList", urlList);
        map.put("userList", userList);
        map.put("invoiceList", invoiceList);
        map.put("deviceInformationList", deviceInformationList);
        return "deviceInformation/detailsSearch";
    }

    //档案证打印
    @GetMapping("{id}/machinery")
    public String machinery(Map<String, Object> map, @PathVariable(required = true) Integer id) throws IOException {
        TbDeviceInformation deviceInformation = new TbDeviceInformation();
        deviceInformation.setId(id);
        List<DeviceInfoMould> machineryDevcieInformationList = deviceInformationService.machineryDevcieInformationList(deviceInformation);
        System.out.println("++++++machineryDevcieInformationList的值=" + machineryDevcieInformationList);
        for (int i = 0; i < machineryDevcieInformationList.size(); i++) {
            machineryDevcieInformationList.get(i).getRegisterName();
            machineryDevcieInformationList.get(i).getFactoryNum();
            machineryDevcieInformationList.get(i).getIdentification();
            String content = "设备产权人:" + machineryDevcieInformationList.get(i).getRegisterName() + "，"
                    + "身份证号:" + machineryDevcieInformationList.get(i).getIdentification() + ","
                    + "设备出厂编号:" + machineryDevcieInformationList.get(i).getFactoryNum() + ","
                    + "抵押状态:" + machineryDevcieInformationList.get(i).getMortgage() + "(注:0为无贷款,1为有贷款)";
            boolean success = new SimpleQrcodeGenerator().setLogo(/*"F:\\二维码\\YZlogo.jpg"*/"/usr/docker/images/Qrcorde/logo/YZlogo.jpg").
                    generate(content).toFile(/*"F:\\二维码\\Qrcode.jpg"*/"/usr/docker/images/Qrcorde/qrcode/qrcode.jpg");
            Assert.assertTrue(success);
            System.out.println("+++++++++++++++++二维码添加完成");
        }
        map.put("machineryDevcieInformationList", machineryDevcieInformationList);
        return "deviceInformation/machinery";
    }

    //声明书打印
    @GetMapping("{factoryNum}/statement")
    public String statement(Map<String, Object> map, @PathVariable(required = true) String factoryNum) {
        TbTransferLicense transferLicense = new TbTransferLicense();
        transferLicense.setFactoryNum(factoryNum);
        //System.out.println("factoryNum=" + factoryNum);
        List<transferLicenseMould> statementDevcieInformationList = transferLicenseService.searchTransferLicenseList(transferLicense);
        System.out.println("++++++statementDevcieInformationList的值=" + statementDevcieInformationList);
        map.put("statementDevcieInformationList", statementDevcieInformationList);
        return "deviceInformation/statement";
    }

    //搜索页面声明书打印
    @GetMapping("{factoryNum}/statementSearch")
    public String statementSearch(Map<String, Object> map, @PathVariable(required = true) String factoryNum) {
        TbTransferLicense transferLicense = new TbTransferLicense();
        transferLicense.setFactoryNum(factoryNum);
       // System.out.println("factoryNum=" + factoryNum);
        List<transferLicenseMould> statementDevcieInformationList = transferLicenseService.searchTransferLicenseList(transferLicense);
        System.out.println("++++++statementDevcieInformationList的值=" + statementDevcieInformationList);
        map.put("statementDevcieInformationList", statementDevcieInformationList);
        return "deviceInformation/statementSearch";
    }

    //委托书打印
    @GetMapping("{factoryNum}/entrust")
    public String entrust(Map<String, Object> map, @PathVariable(required = true) String factoryNum) {
        TbTransferLicense transferLicense = new TbTransferLicense();
        transferLicense.setFactoryNum(factoryNum);
        //System.out.println("factoryNum=" + factoryNum);
        List<transferLicenseMould> entrustDevcieInformationList = transferLicenseService.searchTransferLicenseList(transferLicense);
        System.out.println("++++++entrustDevcieInformationList的值=" + entrustDevcieInformationList);
        map.put("entrustDevcieInformationList", entrustDevcieInformationList);
        return "deviceInformation/entrust";
    }

    //搜索页面委托书打印
    @GetMapping("{factoryNum}/entrustSearch")
    public String entrustSearch(Map<String, Object> map, @PathVariable(required = true) String factoryNum) {
        TbTransferLicense transferLicense = new TbTransferLicense();
        transferLicense.setFactoryNum(factoryNum);
        //System.out.println("factoryNum=" + factoryNum);
        List<transferLicenseMould> entrustDevcieInformationList = transferLicenseService.searchTransferLicenseList(transferLicense);
        System.out.println("++++++entrustDevcieInformationList的值=" + entrustDevcieInformationList);
        map.put("entrustDevcieInformationList", entrustDevcieInformationList);
        return "deviceInformation/entrustSearch";
    }

    //过户表打印
    @GetMapping("{factoryNum}/transfer")
    public String transfer(Map<String, Object> map, @PathVariable(required = true) String factoryNum) {
        TbTransferLicense transferLicense = new TbTransferLicense();
        transferLicense.setFactoryNum(factoryNum);
        //System.out.println("factoryNum=" + factoryNum);
        List<transferLicenseMould> transferList = transferLicenseService.searchTransferLicenseList(transferLicense);
        System.out.println(transferList);
        map.put("transferList", transferList);
        return "deviceInformation/transfer";
    }

    //备案表打印
    @GetMapping("{factoryNum}/register")
    public String register(Map<String, Object> map, @PathVariable(required = true) String factoryNum) {
        TbRegisterLicense tbregisterlicense = new TbRegisterLicense();
        tbregisterlicense.setFactoryNum(factoryNum);
        //System.out.println("factoryNum="+factoryNum);
        List<registerLicenseMould> registerList = registerLicenseService.searchRegisterLicenseList(tbregisterlicense);
        System.out.println(registerList);

        List<String> UrlList = new ArrayList<>();
        List<String> UserList = new ArrayList<>();

        for (int i = 0; i < registerList.size(); i++) {
            String DeviceImg = registerList.get(i).getReferenceDeviceImg();
            String[] urlDeviceList = DeviceImg.split(",");
            for (int j = 0; j < urlDeviceList.length; j++) {
                System.out.println(urlDeviceList[j]);
                UrlList.add(urlDeviceList[j]);
            }
        }
        for (int k = 0; k < registerList.size(); k++) {
            String UserImg = registerList.get(k).getReferenceUserImg();
            String[] urlUserList = UserImg.split(",");
            for (int a = 0; a < urlUserList.length; a++) {
                System.out.println(urlUserList[a]);
                UserList.add(urlUserList[a]);
            }
        }
        map.put("UrlList", UrlList);
        map.put("UserList", UserList);
        map.put("registerList", registerList);
        return "deviceInformation/register";
    }

    //搜索页面备案表打印
    @GetMapping("{factoryNum}/registerSearch")
    public String registerSearch(Map<String, Object> map, @PathVariable(required = true) String factoryNum) {
        TbRegisterLicense tbregisterlicenses = new TbRegisterLicense();
        tbregisterlicenses.setFactoryNum(factoryNum);
       // System.out.println("factoryNum=" + factoryNum);
        List<registerLicenseMould> registerList = registerLicenseService.searchRegisterLicenseList(tbregisterlicenses);
        System.out.println(registerList);
        map.put("registerList", registerList);
        return "deviceInformation/registerSearch";
    }

    //备案登记标志
    @GetMapping("{id}/logo")
    public String logo(Map<String, Object> map, @PathVariable(required = true) Integer id) {
        TbDeviceInformation deviceInformation = new TbDeviceInformation();
        deviceInformation.setId(id);
        List<DeviceInfoMould> logoDevcieInformationList = deviceInformationService.entrustDevcieInformationList(deviceInformation);
       // System.out.println("++++++logoDevcieInformationList的值=" + logoDevcieInformationList);
        map.put("logoDevcieInformationList", logoDevcieInformationList);
        return "deviceInformation/logo";
    }

    //公共号查询设备信息
    @PostMapping("searchIdentificationAndFactoryNum")
    @ResponseBody
    public Object searchIdentificationAndFactoryNum(String gridPager) {
        Pager pager = JsonUtil.getObjectFromJson(gridPager, Pager.class);
        Map<String, Object> parameters = null;
        if (Validator.isNullOrEmpty(pager.getParameters())) {
            parameters = new HashMap<>();
        } else {
            parameters = pager.getParameters();
            Page<TbDeviceInformation> list = deviceInformationService.selectPage(new Page<TbDeviceInformation>
                    (pager.getNowPage(), pager.getPageSize()),
                            Condition.create().eq("factory_num", parameters.get("factoryNum"))
                                              .eq("identification", parameters.get("identification")));
            makeGridResult(parameters, pager, list);
        }
        return parameters;
    }

    //更改读取状态
    @PostMapping("addState")
    @ResponseBody
    public AbstractBean addState(TbDeviceInformation tbdeviceinformation) {
        AbstractBean bean = new AbstractBean();
        //System.out.println("++++++++++++++++++++++++++++++++++++++" + tbdeviceinformation);
        if (!deviceInformationService.insertOrUpdate(tbdeviceinformation)) {
            bean.setStatus(EnumSvrResult.ERROR.getVal());
            bean.setMessage(EnumSvrResult.ERROR.getName());
        }
        return bean;
    }
}
